package com.bw.find_module.find;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.bw.find_module.R;
import com.bw.find_module.attent.AttentFragment;
import com.bw.find_module.recommend.RecommendFragment;
import com.bw.widget_sdk.FragmentAdapter;
import com.flyco.tablayout.SlidingTabLayout;

import java.util.ArrayList;
import java.util.List;

public class FindFragment extends Fragment {
    private View view;
    private ArrayList<Fragment> fragment_list = new ArrayList<>();
    private List<String> titles = new ArrayList<>();
    private SlidingTabLayout recommendTab;
    private ViewPager recommendViewPager;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        fragment_list.add(new AttentFragment());
        fragment_list.add(new RecommendFragment());
        titles.add("关注");
        titles.add("推荐");
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_find, container, false);
        recommendTab = view.findViewById(R.id.recommend_tab);
        recommendViewPager = view.findViewById(R.id.recommend_viewPager);
        FragmentAdapter fragmentAdapter = new FragmentAdapter(getChildFragmentManager(), fragment_list, titles);
        recommendViewPager.setAdapter(fragmentAdapter);
        recommendTab.setViewPager(recommendViewPager);
        return view;
    }
}
